package com.wandian.ui.translation
{
	import flash.events.*;
	import flash.net.*;

	public class ParamsSpecification extends EventDispatcher
	{
		private var fLoaderInfoParams_obj:Object;
		private static var fLanguageXMLUrl_str:String;
		private static var fBuyInCancelJSFunctionName_str:String;
		private static var _currencySignPost:String="";
		public static const EVENT_LANGUAGE_XML_URL_PARAM_UPDATED:String="onLanguageXMLUrlParamUpdated";
		private static var _currencySignPref:String="";
		private static var fBuyInOkJSFunctionName_str:String;
		private static var fRealMode_bl:Boolean;
		private static var fInstance_ps:ParamsSpecification;
		private static var _isCreditsDisplay:Boolean=true;
		private static var fGameSwfDirectoryUrl_str:String;

		public function ParamsSpecification()
		{
			if (ParamsSpecification.fInstance_ps)
			{
				throw Error("Only one ParamsSpecification object can be instantiated.");
			}
			fInstance_ps=this;
			return;
		} // end function

		protected function onLanguageXMLUrlUpdated():void
		{
			this.dispatchEvent(new Event(EVENT_LANGUAGE_XML_URL_PARAM_UPDATED));
			return;
		} // end function

		public function set netDispatcher(param1:NetDispatcher):void
		{
			param1.addEventListener(NetDispatcher.EVENT_NET_RESPONSE_RECEIVED, this.onNetResponseReceived);
			return;
		} // end function

		public function set loaderInfoParams(param1:Object):void
		{
			this.fLoaderInfoParams_obj=param1;
			if (CustomerSpecification.getInstance().readyToUse)
			{
				this.parseLoaderInfoParams();
			}
			else
			{
				CustomerSpecification.getInstance().addEventListener(CustomerSpecification.EVENT_UPDATED, this.parseLoaderInfoParams);
			}
			return;
		} // end function

		public function get languageXMLUrl():String
		{
			trace("ParamsSpecification.languageXMLUrl = " + fLanguageXMLUrl_str);
			return fLanguageXMLUrl_str;
		} // end function

		public function get gameSWFDirectoryUrl():String
		{
			return fGameSwfDirectoryUrl_str;
		} // end function

		public function get loaderInfoParams():Object
		{
			return this.fLoaderInfoParams_obj;
		} // end function

		protected function parseLoaderInfoParams(event:Event=null):void
		{
			trace("ParamsSpecification.parseLoaderInfoParams() called...");
			if (event)
			{
				CustomerSpecification(event.target).removeEventListener(CustomerSpecification.EVENT_UPDATED, this.parseLoaderInfoParams);
			}
			if (CustomerSpecification.getCustomerId() == CustomerSpecification.CUSTOMER_ID_GB)
			{
				ParamsSpecification.fBuyInCancelJSFunctionName_str=this.fLoaderInfoParams_obj["JS_BUYIN_CLOSE_FUNC_NAME"];
				ParamsSpecification.fBuyInOkJSFunctionName_str=this.fLoaderInfoParams_obj["JS_BUYIN_FUNC_NAME"];
			}
			this.languageXmlUrl=this.loaderInfoParams["LANG_XML"] ? (this.loaderInfoParams["LANG_XML"]) : (CustomerSpecification.getLanguageXMLFileUrl());
			if (CustomerSpecification.getCustomerId() == CustomerSpecification.CUSTOMER_ID_AP || CustomerSpecification.getCustomerId() == CustomerSpecification.CUSTOMER_ID_NYX || CustomerSpecification.getCustomerId() == CustomerSpecification.CUSTOMER_ID_AAMS || CustomerSpecification.getCustomerId() == CustomerSpecification.CUSTOMER_ID_RPK || CustomerSpecification.getCustomerId() == CustomerSpecification.CUSTOMER_ID_MRGREEN || CustomerSpecification.getCustomerId() == CustomerSpecification.CUSTOMER_ID_BETKLASS)
			{
				Const.SERVLET_NAME=this.loaderInfoParams["SERVLET_URL"] ? (this.loaderInfoParams["SERVLET_URL"]) : (Const.SERVLET_NAME);
				ParamsSpecification.fBuyInOkJSFunctionName_str=this.fLoaderInfoParams_obj["JS_BUYIN_FUNC_NAME"];
			}
			if (CustomerSpecification.getCustomerId() == CustomerSpecification.CUSTOMER_ID_BS)
			{
				Const.SERVLET_NAME=this.loaderInfoParams["SERVLET_URL"];
				trace("[ParamsSpecification]: Const.SERVLET_NAME " + Const.SERVLET_NAME);
			}
			return;
		} // end function

		protected function onNetResponseReceived(event:Event):void
		{
			var _loc_2:URLVariables=null;
			trace("ParamsSpecification.onNetResponseReceived() called");
			_loc_2=NetDispatcher(event.target).response;
			trace("ParamsSpecification.onNetResponseReceived(): requestCommand = " + NetDispatcher(event.target).requestCommand);
			if (NetDispatcher(event.target).requestCommand == NetDispatcher.ACTION_ENTER)
			{
				switch (CustomerSpecification.getCustomerId())
				{
					case CustomerSpecification.CUSTOMER_ID_GB:
					{
						trace("ParamsSpecification.onNetResponseReceived(): lResponse_urlv.game_mode = " + _loc_2.game_mode);
						ParamsSpecification.fRealMode_bl=_loc_2.game_mode == "real";
						break;
					}
					case CustomerSpecification.CUSTOMER_ID_GV:
					{
						trace("ParamsSpecification.onNetResponseReceived(): lResponse_urlv.game_mode = " + _loc_2.game_mode);
						ParamsSpecification.fRealMode_bl=_loc_2.game_mode == "real";
						break;
					}
					case CustomerSpecification.CUSTOMER_ID_AP:
					case CustomerSpecification.CUSTOMER_ID_NYX:
					case CustomerSpecification.CUSTOMER_ID_AAMS:
					case CustomerSpecification.CUSTOMER_ID_BETKLASS:
					case CustomerSpecification.CUSTOMER_ID_RPK:
					case CustomerSpecification.CUSTOMER_ID_MRGREEN:
					{
						ParamsSpecification.fRealMode_bl=_loc_2.game_mode == "real";
						break;
					}
					default:
					{
						break;
					}
				}
			}
			return;
		} // end function

		public function set gameSWFDirectoryUrl(param1:String):void
		{
			fGameSwfDirectoryUrl_str=param1;
			return;
		} // end function

		protected function set languageXmlUrl(param1:String):void
		{
			fLanguageXMLUrl_str=param1;
			this.onLanguageXMLUrlUpdated();
			return;
		} // end function

		public static function getInstance():ParamsSpecification
		{
			if (!fInstance_ps)
			{
				new ParamsSpecification;
			}
			return fInstance_ps;
		} // end function

		public static function get isCreditsDisplay():Boolean
		{
			return _isCreditsDisplay;
		} // end function

		public static function setRealMode(param1:Boolean):void
		{
			fRealMode_bl=param1;
			return;
		} // end function

		public static function set isCreditsDisplay(param1:Boolean):void
		{
			_isCreditsDisplay=param1;
			return;
		} // end function

		public static function getBuyInCancelJSFunctionName():String
		{
			return ParamsSpecification.fBuyInCancelJSFunctionName_str;
		} // end function

		public static function isRealMode():Boolean
		{
			return fRealMode_bl;
		} // end function

		public static function setCurrencySign(param1:String, param2:String):void
		{
			_currencySignPref=param1;
			_currencySignPost=param2;
			return;
		} // end function

		public static function formatCurrencyWithSign(param1:Number):String
		{
			var _loc_2:String=null;
			_loc_2=_currencySignPref + Tools.formatCurrency(param1) + _currencySignPost;
			if (_currencySignPref == "£")
			{
				_loc_2="<font face=\'Arial\'>" + _currencySignPref + "</font>" + Tools.formatCurrency(param1) + _currencySignPost;
			}
			return _loc_2;
		} // end function

		public static function getCurrencySign():Object
		{
			return {prefix: _currencySignPref, postfix: _currencySignPost};
		} // end function

		public static function getBuyInOkJSFunctionName():String
		{
			return ParamsSpecification.fBuyInOkJSFunctionName_str;
		} // end function

	}
}
